﻿// -------------------------------------------------------------------------
//    @FileName         :    NFLicensePart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFLicensePart
//
// -------------------------------------------------------------------------

#include "NFLicensePart.h"

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFLicensePart::NFLicensePart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFLicensePart::~NFLicensePart()
{
}

int NFLicensePart::CreateInit()
{
    return 0;
}

int NFLicensePart::ResumeInit()
{
    return 0;
}

int NFLicensePart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().license_data());
    return 0;
}

int NFLicensePart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    auto pLicenseData = pDbData->mutable_role_play_data()->mutable_license_data();
    CHECK_NULL(0, pLicenseData);

    RoleLicenseData stData;
    stData.block_bit_map.resize(stData.block_bit_map.max_size());
    stData.is_open = false;
    stData.exchange_lp = 1;
    stData.cur_lp = 1;

    /*const CDescStoreLicense *pDescStoreLicense = CDescUtil::GetDescStoreLicense();
    int iStartRow = 0;
    int iStartCol = 0;
    pDescStoreLicense->GetStartBlockPos(iStartRow, iStartCol);

    SET_BITS(stData.block_bit_map[ iStartRow - 1], 1 << (iStartCol - 1));*/

    stData.ToPb(pLicenseData);
    return 0;
}

int NFLicensePart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_license_data());
    return 0;
}

int NFLicensePart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_license_data());
    return 0;
}

int NFLicensePart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
